package br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin;

import br.edu.ufcg.lsd.wbis.ui.client.ui.management.PanelManager;

import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;

/**
 * @author Renato Miceli
 */
public class LogoutButtonListener extends ButtonListenerAdapter {

	private final PanelManager panelsManager;

	public LogoutButtonListener(PanelManager panelsManager) {
		this.panelsManager = panelsManager;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void onClick(Button button, EventObject e) {
		MessageBox.confirm("Logout", "Are you sure you wish to logout? ", new MessageBox.ConfirmCallback() {
			public void execute(String btnID) {
				if (btnID.equals("yes")) {
					panelsManager.switchToLoginPanel();
				}
			}
		});
	}

}
